package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.Contract;
import com.ruoyi.personnel.mapper.ContractMapper;
import com.ruoyi.personnel.service.IContractService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 合同信息Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-24
 */
@Service
public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> implements IContractService {

    @Override
    public List<Contract> queryList(Contract contract) {
        LambdaQueryWrapper<Contract> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(contract.getName())){
            lqw.like(Contract::getName ,contract.getName());
        }
        if (StringUtils.isNotBlank(contract.getPersonnelId())){
            lqw.eq(Contract::getPersonnelId ,contract.getPersonnelId());
        }
        if (StringUtils.isNotBlank(contract.getJobNumber())){
            lqw.eq(Contract::getJobNumber ,contract.getJobNumber());
        }
        if (StringUtils.isNotBlank(contract.getContractStart())){
            lqw.eq(Contract::getContractStart ,contract.getContractStart());
        }
        if (StringUtils.isNotBlank(contract.getContractEnd())){
            lqw.eq(Contract::getContractEnd ,contract.getContractEnd());
        }
        if (StringUtils.isNotBlank(contract.getContractType())){
            lqw.eq(Contract::getContractType ,contract.getContractType());
        }
        if (StringUtils.isNotBlank(contract.getProbationPeriod())){
            lqw.eq(Contract::getProbationPeriod ,contract.getProbationPeriod());
        }
        if (StringUtils.isNotBlank(contract.getPost())){
            lqw.eq(Contract::getPost ,contract.getPost());
        }
        if (StringUtils.isNotBlank(contract.getEnclosure())){
            lqw.eq(Contract::getEnclosure ,contract.getEnclosure());
        }
        return this.list(lqw);
    }
}
